<ul id="leftMenu">

    {foreach $admin_modules as $k=>$subactions}
    <li class="nav" id="nav_{$k}">
        <span class="icon-home"></span>
        <a href="#">{$lang.$k.pn}</a>

        <ul class="subNav">
            {foreach $subactions as $s=>$v}
            <li id="subNav_{$s}">
                <a href="{$config.docroot}{$v}/{if $k neq "admin_blog"}{$req.default_index}{/if}" {if $k eq "admin_blog"}target="_blank"{/if}>{$lang.$k.$s.pn}</a>
            </li>
            {/foreach}
        </ul>

    </li>
    {/foreach}

</ul>

{capture "js_leftmenu"}

{literal}
$('#leftmenu .menu-item').on('click','.admin-subpage',function(e){

console.log('clicked');
var $submenu = $('#leftmenu #sub' + $(this).attr('id'));
console.log($submenu.css('display'));
if($submenu.css('display') == 'none')
{
$('#leftmenu .submenu').slideUp();
$submenu.slideDown();
}
e.preventDefault();
});
{/literal}

$('#leftmenu #menu-{$pv.admin_page}').trigger('click');
{if $pv.admin_request neq ''}
var $tmp = $('#leftmenu #submenu-{$pv.admin_page} li#{$pv.admin_request}');
$tmp.addClass('active');
$tmp.find('a').addClass('active');
{/if}
{/capture}